﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using System.Xml.Serialization;

namespace DataItems
{
    public class Map
    {
        private string name;
        public string Name 
        {
            get { return name; }
            set { name = value; }
        }

        private int width;
        public int Width
        {
            get { return width; }
            set { width = value; }
        }

        private int height;
        public int Height
        {
            get { return height; }
            set { height = value; }
        }

        private int tilewidth;
        public int TileWidth
        {
            get { return tilewidth; }
            set { tilewidth = value; }
        }

        private int tileheight;
        public int TileHeight
        {
            get { return tileheight; }
            set { tileheight = value; }
        }

        private string textureName;
        public string TextureName
        {
            get { return textureName; }
            set { textureName = value; }
        }

        private Texture2D texture;
        [ContentSerializerIgnore]
        public Texture2D Texture
        {
            get { return texture; }
        }

        private List<Portal> portals = new List<Portal>();
        public List<Portal> Portals
        {
            get { return portals; }
            set { portals = value; }
        }

        public Portal FindPortal(string name)
        {
            // check the parameter
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            for (int i = 0; i < portals.Count; i++)
            {
                if (portals[i].Name == name)
                    return portals[i];
            }
            return null;
        }

        private List<Npc> npsPeople = new List<Npc>();
        public List<Npc> NpsPeople
        {
            get { return npsPeople; }
            set { npsPeople = value; }
        }

        private List<Monster> monsters = new List<Monster>();
        public List<Monster> Monsters
        {
            get { return monsters; }
            set { monsters = value; }
        }

        private List<tileset> tileSets = new List<tileset>();
        public List<tileset> TileSets
        {
            get { return tileSets; }
            set { tileSets = value; }
        }

        class tileset
        {
            private string name;
            public string Name
            {
                get { return name; }
                set { name = value; }
            }

            private string textureName;
            public string TextureName
            {
                get { return textureName; }
                set { textureName = value; }
            }


            private int id;
            /// <summary>
            /// Used for identifying what the tile is in the map array
            /// </summary>
            public int Id
            {
                get { return id; }
                set { id = value; }
            }

            private int tilewidth;
            public int TileWidth
            {
                get { return tilewidth; }
                set { tilewidth = value; }
            }

            private int tileheight;
            public int TileHeight
            {
                get { return tileheight; }
                set { tileheight = value; }
            }

            private string movable;
            public string Movable
            {
                get { return movable; }
                set { movable = value; }
            }
        }
    }

}
